home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / lightwave / lwmlist / 95.lightwave-10 / 001587_owner-lightwav…mail.webcom.com_Sun Oct 29 12:02:59 1995.msg < prev    next >
Internet Message Format  |  1995-11-07  |  8KB

  1. Received: by mail.webcom.com
  2.     (1.37.109.15/16.2) id AA118306979; Sun, 29 Oct 1995 12:02:59 -0800
  3. Return-Path: <owner-lightwave@mail.webcom.com>
  4. Received: from netcom15.netcom.com by mail.webcom.com with ESMTP
  5.     (1.37.109.15/16.2) id AA118246975; Sun, 29 Oct 1995 12:02:55 -0800
  6. Received: by netcom15.netcom.com (8.6.12/Netcom)
  7.     id LAA06722; Sun, 29 Oct 1995 11:54:38 -0800
  8. From: bhood@netcom.com (robert hood)
  9. Message-Id: <199510291954.LAA06722@netcom15.netcom.com>
  10. Subject: Batch Rendering ala BML!
  11. To: lightwave@mail.webcom.com
  12. Date: Sun, 29 Oct 1995 11:54:38 -0800 (PST)
  13. Cc: lwplugin-l@netcom.com
  14. X-Mailer: ELM [version 2.4 PL23]
  15. Mime-Version: 1.0
  16. Content-Type: text/plain; charset=US-ASCII
  17. Content-Transfer-Encoding: 7bit
  18. Content-Length: 7065      
  19. Sender: owner-lightwave@mail.webcom.com
  20. Precedence: bulk
  21.  
  22. Here is a BML script (long) that batch renders one or more scene files using
  23. ScreamerNet II.  Sorry for the length.  =|^)
  24.  
  25. ------------------------------------------------------------------------------
  26. // BATCH.BML
  27. //
  28. // An interface script to batch scene rendering with ScreamerNet II.  This is
  29. // not intended to be use by a render farm as it currently exists, but rather
  30. // as a demonstration.
  31. //
  32. // It expects a text file to reside in the root directory called "batch.txt"
  33. // that contains one line for each scene to be rendered, in the following
  34. // format:
  35. //
  36. //    <scene file name> <first frame> <last frame> [<RGB name> [<Alpha name>]]
  37. //
  38. // for example,
  39. //
  40. //    \lw\atom\atom.lws 1 3 \atom
  41. //    \lw\curtain\curtain.lws 1 1 \curt
  42. //
  43. // It also manually invokes ScreamerNet on the local machine.  In the real
  44. // world, SNII would already be running on one or more machines, and the
  45. // script would only have to interface with the SNII job/reply files.
  46. //
  47. // (this script actually works, by the way. =|^)
  48.  
  49. // we must specify 'asyncspawn' so that SNII runs in parallel with us
  50.  
  51. #pragma asyncspawn
  52.  
  53. // these variables must be global because they could potentially be
  54. // referenced by the ONERROR handler below
  55.  
  56. var commandFile,replyFile;
  57. var batchFile,snID;
  58. var tmp = getenv("TMP");
  59.  
  60. main
  61. {
  62.     var batchItems[5];
  63.     var commandName = string(tmp,"\snii.job");
  64.     var str;
  65.     var timeout;
  66.  
  67.     batchItems[] = nil;     // initialize the array
  68.  
  69.     filedelete(commandName);
  70.     filedelete(tmp,"\snii.rpl");
  71.  
  72.     commandFile = file(commandName,"w");
  73.     if(commandFile == nil)
  74.     {
  75.         error("Cannot create ScreamerNet job file");
  76.         return;
  77.     }
  78.     commandFile.writeln("init");
  79.     commandFile.close();
  80.  
  81.     str = string(tmp,"\snii.rpl");
  82.     replyFile = file(str,"w");
  83.     replyFile.close();
  84.  
  85.     replyFile.open(str,"r");
  86.     if(replyFile.isOpen() == false)
  87.     {
  88.         error("Cannot create ScreamerNet reply file");
  89.         filedelete(tmp,"\snii.job");
  90.         return;
  91.     }
  92.  
  93.     // now open the batch file
  94.  
  95.     batchFile = file("\batch.txt","r");
  96.     if(batchFile == nil)
  97.     {
  98.         error("Cannot open batch file");
  99.  
  100.         replyFile.close();
  101.  
  102.         filedelete(tmp,"\snii.job");
  103.         filedelete(tmp,"\snii.rpl");
  104.  
  105.         return;
  106.     }
  107.  
  108.     // ideally, ScreamerNet would already be running on one or
  109.     // more machines.  we'll run it locally just for purposes of
  110.     // making this script work.
  111.  
  112.     snID = spawn("\windows\apps\newtek\programs\lwsn -2 ",
  113.                  tmp,"\snii.job ",
  114.                  tmp,"\snii.rpl");
  115.     if(snID == nil)
  116.     {
  117.         error("Cannot create ScreamerNet process");
  118.         replyFile.close();
  119.  
  120.         filedelete(tmp,"\snii.job");
  121.         filedelete(tmp,"\snii.rpl");
  122.  
  123.         return;
  124.     }
  125.  
  126.     // Ok, ScreamerNet II is running in parallel with us, watching
  127.     // 'snii.job' for commands.  We will watch 'snii.rpl' for its replies
  128.  
  129.     timeout = 6;
  130.     replyFile.rewind();
  131.     while(replyFile.read() != "Initializing" && timeout)
  132.     {
  133.         sleep(10);           // sleep for 10 seconds
  134.         --timeout;
  135.     }
  136.  
  137.     if(timeout == 0)
  138.     {
  139.         error("Communication error with ScreamerNet process");
  140.         replyFile.close();
  141.  
  142.         filedelete(tmp,"\snii.job");
  143.         filedelete(tmp,"\snii.rpl");
  144.  
  145.         return;
  146.     }
  147.  
  148.     moninit(batchFile.lines() + 1,"Rendering scenes...");
  149.  
  150.     monstep();  // try to get the monitor dialog up sooner
  151.  
  152.     batchItems = batchFile.parse(" ");
  153.  
  154.     while(batchFile.eof() == false)
  155.     {
  156.         commandFile.open(commandName,"w");
  157.         commandFile.writeln("load ",batchItems[1]);
  158.         commandFile.close();
  159.  
  160.         sleep(2);           // sleep for 2 seconds
  161.  
  162.         replyFile.rewind();
  163.         if(replyFile.read() != "Loading")
  164.         {
  165.             error("Communication error with ScreamerNet process");
  166.             replyFile.close();
  167.             batchFile.close();
  168.  
  169.             filedelete(tmp,"\snii.job");
  170.             filedelete(tmp,"\snii.rpl");
  171.  
  172.             terminate(snID);    // kill ScreamerNet
  173.  
  174.             return;
  175.         }
  176.  
  177.         // issue the SN "output" command if parameters have been specified
  178.  
  179.         if(batchItems[4] != nil)
  180.         {
  181.             commandFile.open(commandName,"w");
  182.  
  183.             // is the Alpha channel indicated also?
  184.  
  185.             if(batchItems[5] != nil)
  186.                 commandFile.writeln("output ",batchItems[4]," ",batchItems[5]);
  187.             else
  188.                 commandFile.writeln("output ",batchItems[4]," (none)");
  189.             commandFile.close();
  190.  
  191.             timeout = 6;        // wait up to 30 seconds
  192.             replyFile.rewind();
  193.             while(replyFile.read() != "Setting output file options" && timeout)
  194.             {
  195.                 sleep(5);       // sleep 5 seconds
  196.                 --timeout;
  197.                 replyFile.rewind();
  198.             }
  199.         }
  200.  
  201.         commandFile.open(commandName,"w");
  202.         commandFile.writeln("render ",batchItems[2]," ",batchItems[3]," 1");
  203.         commandFile.close();
  204.  
  205.         sleep(5);           // give it a chance to pick up the command
  206.  
  207.         // Excuse me, but why can't SNII tell us when it is finished
  208.         // rendering?
  209.  
  210.         commandFile.open(commandName,"w");
  211.         commandFile.writeln("init");
  212.         commandFile.close();
  213.  
  214.         replyFile.rewind();
  215.         while(replyFile.read() != "Initializing")
  216.         {
  217.             sleep(60);       // sleep 1 minute
  218.             replyFile.rewind();
  219.         }
  220.  
  221.         if(monstep())
  222.             break;
  223.  
  224.         batchItems = batchFile.parse(" ");
  225.     }
  226.  
  227.     monend();
  228.  
  229.     terminate(snID);    // shut down ScreamerNet
  230.  
  231.     replyFile.close();
  232.     batchFile.close();
  233.  
  234.     filedelete(commandName);
  235.     filedelete(tmp,"\snii.rpl");
  236. }
  237.  
  238. // cleanup handler -- we need this because BML is not aware
  239. // of processes spawned by it's scripts
  240.  
  241. // ONERROR is an automatic function invoked by BML, if it
  242. // is defined, when run-time errors occur.  Run-time errors
  243. // such as accessing uninitialized variables and the like that
  244. // the programmer introduces.  If 'autoerror' is specified,
  245. // then command/function errors will also invoke this function.
  246.  
  247. ONERROR
  248. {
  249.     commandFile.close();
  250.     replyFile.close();
  251.     batchFile.close();
  252.  
  253.     filedelete(tmp,"\snii.job");
  254.     filedelete(tmp,"\snii.rpl");
  255.  
  256.     terminate(snID);    // shut down ScreamerNet
  257. }
  258. ------------------------------------------------------------------------------
  259.  
  260. Render me gone,               |||
  261. Bob                         ^(===)^
  262. -------------------------oOO--(_)--OOo--------------------------------------
  263. Bob Hood            | Bureaucracy destroys initiative.  There is little that
  264.                     | bureaucrats hate more than innovation, especially
  265. Work: 303-730-1324  | innovation that produces better results than the old
  266. Home: 303-980-8392  | routines.  Improvements always make those at the top
  267. bhood@netcom.com    | of the heap look inept.  Who enjoys appearing inept?
  268. hood@cqgrd.com      |                               - Frank Herbert
  269. ----------------------------------------------------------------------------
  270. --
  271. bhood@netcom.com (robert hood) sent this message.
  272. To Post a Message           : lightwave@webcom.com
  273. Un/Subscription Requests To : lightwave-request@webcom.com
  274. (DIGEST)                 or : lightwave-digest-request@webcom.com
  275. Administrative Items To     : owner-lightwave@webcom.com